#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdbool.h>
bool jugde_year(int x)
{
	if ((x % 4 == 0 && x % 100 != 0) || (x % 400 == 0))
		return true;
	else
		return false;

	
}
//int jugde_year(int x)
//{
//	if ((x % 4 == 0 && x % 100 != 0) || (x % 400 == 0))
//	else
//		return 0;


//}
int get_days_of_month(int x,int y)
{
	int days[] = {0,31,28,31,30,51,30,31,31,30,31,30,31 };
	int day = days[y];
	if (jugde_year(x) == 1 && y == 2)
		day++;
	return day;

}
int main()
{
	int year = 0;
	int month = 0;
	scanf("%d %d", &year, &month);
	int day = get_days_of_month(year,month);
	printf("%d\n", day);
	return 0;
}